home *** CD-ROM | disk | FTP | other *** search
- Path: solon.com!not-for-mail
- From: seebs@solutions.solon.com (Peter Seebach)
- Newsgroups: comp.lang.c
- Subject: Re: quick decision: is n a power of 2?
- Date: 20 Jan 1996 11:04:28 -0600
- Organization: Usenet Fact Police (Undercover)
- Message-ID: <4dr7as$s1@solutions.solon.com>
- References: <4dorr8$i58@cloner3.netcom.com> <4dp2no$3va@unix.sri.com> <TANMOY.96Jan19220222@qcd.lanl.gov>
- NNTP-Posting-Host: solutions.solon.com
-
- In article <TANMOY.96Jan19220222@qcd.lanl.gov>,
- Tanmoy Bhattacharya <tanmoy@qcd.lanl.gov> wrote:
- >Don't think, try
-
- >#define POWER(x) (!((x) & ((x)-1)))
-
- >on unsigned types.
-
- It reports that 0 is a power of 2.
-
- Very clever, though.
-
- -s
- --
- Peter Seebach - seebs@solon.com - Copyright 1995 Peter Seebach.
- C/Unix proto-wizard -- C/Unix questions? Send mail for help. No, really!
- Using trn? Weird new newsgroup problem? I know the fix! Email me!
- The *other* C FAQ - ftp taniemarie.solon.com /pub/c/afq - Not A Flying Toy
-